package arkham.data;

import java.util.*;
import arkham.jaxb.resource.*;

public class ResourceSet {
	
	private HashMap<String, String> icons;
	private static ResourceSet gameResources;
	
	private ResourceSet()
	{
		icons = new HashMap<String, String>();
	}
	
	/**
	 * Checks if the resource set has an icon
	 * @param name 
	 * @return
	 */
	public boolean hasIcon(String name)
	{
		return icons.containsKey(name);
	}
	
	/**
	 * Gets the filename corresponding to a type of icon in the game
	 * @param name the name of the icon
	 * @return the filename of the icon
	 */
	public String getIconFilename(String name)
	{
		return icons.get(name);
	}
	
	/**
	 * Called by game loader to load an XML data of the resource set
	 * into memory
	 * @param xmlset the XML resource set
	 */
	public void addToResourceSet(ResourceSetType xmlset)
	{
		for (ResourceType res : xmlset.getIcon())
		{
			icons.put(res.getName(), res.getDetails());
		}
	}
	
	/**
	 * Gets the global instance of resource set.
	 * @return the resource set
	 */
	public static ResourceSet getInstance()
	{
		if (gameResources == null)
		{
			gameResources = new ResourceSet();
		}
		return gameResources;
	}
	
}
